package com.neusoft.dibuy.ipsumspringbootstarter.configuration;

import com.neusoft.dibuy.ipsumspringbootstarter.properties.SmsProperties;
import com.neusoft.dibuy.ipsumspringbootstarter.service.SmsService;
import com.neusoft.dibuy.ipsumspringbootstarter.service.SmsTemplate;
import com.neusoft.dibuy.ipsumspringbootstarter.service.impl.AliCloudSmsServiceImpl;
import com.neusoft.dibuy.ipsumspringbootstarter.service.impl.TxCloudSmsServiceImpl;
import com.neusoft.dibuy.ipsumspringbootstarter.service.impl.YmxCloudSmsServiceImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@AutoConfiguration
@ConditionalOnClass(SmsTemplate.class)
@EnableConfigurationProperties(value = SmsProperties.class)
@Import({SmsService.class, SmsProperties.class})
public class SmsAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public SmsTemplate smsTemplate(){
        return new SmsTemplate();
    }

    @Bean("aly")
    public SmsService smsService(){
        return new AliCloudSmsServiceImpl();
    }
    @Bean("tx")
    public SmsService tx(){
        return new TxCloudSmsServiceImpl();
    }
    @Bean("ymx")
    public SmsService yms(){
        return new YmxCloudSmsServiceImpl();
    }

}